/**
 * 
 */
package robot;

import javax.vecmath.Point2d;
import javax.vecmath.Vector3d;
import program.MovingObjects;

/**
 * Moves in a circle
 * @date 7 maj 2012
 * @version 1.0
 */
public class DaggensRobot extends Robot {
	private int pathIndex = 0;
	
	/** follow this path around and around */
	private Point2d[] path;

	/**
	 * @param position start
	 * @param name
	 * @param mo
	 */
	public DaggensRobot(Vector3d startPosition, String name,
			MovingObjects mo) {
		this(startPosition, name, mo, new Point2d[] {new Point2d(-2,-2)});		
		
	}
	
	public DaggensRobot (Vector3d startPosition, String name,
			MovingObjects mo, Point2d[] path) {
		super(startPosition, name, mo);
		this.path = path;
	}	

	/* (non-Javadoc)
	 * @see program.Robot#performBehavior()
	 */
	@Override
	public void performBehavior() {
		updateRoboMap();
		rotateTowardsNextGoal(this.path[pathIndex]);
		setTranslationalVelocity(1);
		    
	    if (this.getCurrentPosition().distance(this.path[pathIndex]) < 0.1) {
	    	pathIndex = (pathIndex + 1) % path.length;
            rotateTowardsNextGoal(path[pathIndex]);
	    }
	}

}
